{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "84cca202",
   "metadata": {},
   "source": [
    "import sqlite3\n",
    "\n",
    "# 连接数据库\n",
    "conn = sqlite3.connect('users.db')\n",
    "cursor = conn.cursor()\n",
    "\n",
    "# 创建表\n",
    "cursor.execute('''\n",
    "    CREATE TABLE IF NOT EXISTS users (\n",
    "        names TEXT PRIMARY KEY AUTOINCREMENT,\n",
    "        passwords TEXT\n",
    "    )\n",
    "''')\n",
    "\n",
    "# 插入数据\n",
    "cursor.execute('INSERT INTO users (names, passwords) VALUES (?, ?)', ('张三', '25s12'))\n",
    "conn.commit()\n",
    "\n",
    "# 查询数据\n",
    "cursor.execute('SELECT * FROM users')\n",
    "print(cursor.fetchall())\n",
    "\n",
    "# 关闭连接\n",
    "conn.close()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
